﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">


    <!-- Simple ListBox - This uses SimpleScrollViewer to allow items to be scrolled and SimpleListBoxItem to define the look of each item -->
    <Style TargetType="{x:Type ListBox}" x:Key="{x:Type ListBox}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="Foreground" Value="{DynamicResource Foreground}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Grid>
                        <Border Name="Border">
                            <Border BorderThickness="0.5,1,0,0" BorderBrush="{DynamicResource BrushDarkness}" 
                                    Background="{DynamicResource BrushMedium}" 
											CornerRadius="2,3,2,2"  SnapsToDevicePixels="True">
                                <ScrollViewer Margin="1" Focusable="false" Background="Transparent">

                                    <!-- The StackPanel is used to display the children by setting IsItemsHost to be Trus -->
                                    <StackPanel Margin="2" IsItemsHost="true"/>

                                </ScrollViewer>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="{DynamicResource BrushDisabledSunkenBackground}" TargetName="Border"/>
                            <Setter Property="Foreground" Value="{DynamicResource BrushDisabledForeground}"/>
                            <Setter Property="Opacity" Value="0.75"/>
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Simple ListBoxItem - This is used for each Item in a ListBox. The item's content is placed in the ContentPresenter -->

    <Style TargetType="{x:Type ListBoxItem}" x:Key="{x:Type ListBoxItem}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="Foreground" Value="{DynamicResource Foreground}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Grid SnapsToDevicePixels="true" Margin="0">
                        <Border x:Name="Border" Margin="0" Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
                        <ContentPresenter />
                    </Grid>
                    <ControlTemplate.Triggers>

                        <!-- Change IsSelected SelectedBackgroundBrush to set the selection color for the items -->
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background" Value="{DynamicResource BrushMedium}" TargetName="Border"/>
                            <Setter Property="Foreground" Value="{DynamicResource BrushOffWhite}" />
                        </Trigger>

                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource BrushDisabledSunkenBackground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>